import React, { Component } from 'react';

class Effectclass extends Component {
  constructor() {
    super();
    this.state = {
      // 点击次数
      count: 0
    }
  }
  changeCount() {
    this.setState({
      count: this.state.count + 1
    }, ()=>{
      document.title = `当前点击次数:${this.state.count}`;
    })
  }
  componentDidMount() {
    document.title = `当前点击次数:${this.state.count}`;
  }
  render() {
    return (
      <div>
        <p>需求：点击按钮，修改count，而且页面的标题也会更新，显示点击的次数</p>
        <button onClick={()=>this.changeCount()}>当前点击次数:{this.state.count}</button>
      </div>
    );
  }
}

export default Effectclass;
